//
//  PushActivityView.m
//  YIJU2.0-HD
//
//  Created by 张金国 on 16/5/16.
//  Copyright © 2016年 张金国. All rights reserved.
//

#import "PushActivityView.h"
#import "PushActivityCustomCellModel.h"
//#import "PushActivityCustomCell.h"
#import "Masonry.h"
#import "Macro.h"

@interface PushActivityView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong)UITableView   *tableView;

@property (nonatomic, strong) NSMutableArray *model;


@end

@implementation PushActivityView
#pragma mark - init
- (instancetype)init {
    
    if (self == [super init]) {
        
        PushActivityCustomCellModel *model = [[PushActivityCustomCellModel alloc]init];
        [self.model addObject:model];
        model.tagName = @"团购";
        model.title = @"宜居花园项目开盘疯狂团购";
        model.timestamp = 2345;
        model.iconURL = @"check";
        model.introduction = @"         aewfjajfoadisvdmnvodvndnoviaoigoadinvoanodfnbuonoanvoannacsdnvjanbfjandjbnvajndjvnajdnvjandvjnajdn avkjnvjknfdnvanvadnfjkvn";
        
        PushActivityCustomCellModel *model2 = [[PushActivityCustomCellModel alloc]init];
        [self.model addObject:model2];
        model2.tagName = @"团购";
        model2.title = @"宜居花园项目开盘疯狂团购";
        model2.timestamp = 2345;
        model2.iconURL = @"check";
        model2.introduction = @"         aewfjajfoadisvdmnvodvndnoviaoigoadinvoanodfnbuonoanvoannacsdnvjanbfjandjbnvajndjvnajdnvjandvjnajdn avkjnvjknfdnvanvadnfjkvn";
        [self setupConstraints];
        }
    
    
        return self;
}

#pragma mark -<UITableViewDelegate,UITableViewDataSource>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return self.model.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    id<CustomCellModel> cellModel = [self.model objectAtIndex:indexPath.row];
    UITableViewCell *cell = [UITableViewCell tableView:tableView cellWithModel:cellModel];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0;
}

#pragma mark - private
- (void)setupConstraints {
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(70);
            make.left.right.bottom.equalTo(self);
        }];
}

#pragma mark - getter
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.rowHeight = UITableViewAutomaticDimension;
        _tableView.estimatedRowHeight = 100;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.sectionFooterHeight = 6.0;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = kUserInfoViewBackgroundColor;
        [self addSubview:_tableView];
    }
    return _tableView;
}

- (NSMutableArray *)model{
    if (_model == nil) {
        _model = [NSMutableArray array];
    }
    return _model;
}


@end
